<!--新增会员-->
<template>
  <section class="webview fixHeight">
    <el-scrollbar style="height:100%">
     
     
      <!--      会员-->
      <el-form  ref="form" :model="detail" label-width="100px" class="form">
        <el-form-item label="头像">
          <div class="picList">
            <div  class="item">
              <img class="pic" :src="detail.headPortrait" alt>
              
            </div>
          </div>
        </el-form-item>
        <el-form-item label="用户名">
          <el-input v-model="detail.name" />
        </el-form-item>
        <el-form-item label="所属公司">
          <el-input  v-model="detail.enterpriseName" />
        </el-form-item>
		 <el-form-item label="所属公司">
          <el-input  v-model="detail.enterpriseName" />
        </el-form-item>
		<el-form-item label="从业年限">
			<el-input v-model="detail.designYear" />
		</el-form-item>
		<el-form-item label="设计报价"  v-if='type==0'>
			<el-input v-model="detail.designPirce"/>
		</el-form-item>
		<el-form-item label="个人介绍">
			<el-input v-model="detail.introduce"   type="textarea" :rows="4"/>
		</el-form-item>
		<el-form-item label="擅长风格" v-if='type==0'>
		  <el-select v-model="detail.style" multiple placeholder="请选择">
		    <el-option
		      v-for="item in detail.style"
		      :key="item"
		      :label="item"
		      :value="item"
		    />
		  </el-select>
		</el-form-item>
       <!-- <el-form-item label="邮箱">
          <el-input v-model="detail.email" />
        </el-form-item> -->
        <el-form-item label="手机号">
          <el-input v-model="detail.phone" />
        </el-form-item>
		<el-form-item label="等级设置" v-if='type == 0'>
			<el-select v-model="detail.level" placeholder="请选择">
			  <el-option
			    v-for="item in level"
			    :key="item.lev"
			    :label="item.name"
			    :value="item.lev"
			  />
			</el-select>
		</el-form-item>
        <el-form-item>
         <el-button type="primary" v-if='type == 0' @click="submit">提交</el-button>
          <el-button @click="cancel">返回</el-button>
        </el-form-item>
      </el-form>
    </el-scrollbar>
  </section>
</template>
<script>
  import { detailDesigner,detailHomeHold,detailHomeDecoration,updateDesigner,updateHomeDecoration,updateHomeHold } from '@/api/api'
  export default {
    data() {
      return {
		  type:0,
		  level:[{
			  lev:1,
			  name:'初级'
		  },{
			  lev:2,
			  name:'中级'
		  },{
			  lev:3,
			  name:'高级'
		  }],
        detail: {}
      }
    },
    created() {
		this.type=this.$route.query.type
     if(this.$route.query.type==1){
		 
		 detailHomeHold(this.$route.query.id).then(data => {
		 		 if(data.code==200){
		 			 this.detail=data.data
		 		 }
		 })
	 }else if(this.$route.query.type==0){
		 detailDesigner(this.$route.query.id).then(data => {
		 		 if(data.code==200){
		 			 this.detail=data.data
		 		 }
		 })
	 }else if(this.$route.query.type==2){
		 detailHomeDecoration(this.$route.query.id).then(data => {
		 		 if(data.code==200){
		 			 this.detail=data.data
		 		 }
		 })
	 }
	
    },
    methods: {
      submit(){
		  
		  if(this.$route.query.type==1){
		  		 
		  		 updateHomeHold(this.detail).then(data => {
		  		 		 if(data.code==200){
		  		 			 detailHomeHold(this.$route.query.id).then(data => {
		  		 			 		 if(data.code==200){
		  		 			 			 this.detail=data.data
		  		 			 		 }
		  		 			 })
		  		 		 }
		  		 })
		  }else if(this.$route.query.type==0){
			  this.detail.apartmentType= this.detail.apartmentType.join(',')
			  this.detail.style= this.detail.style.join(',')
		  		 updateDesigner(this.detail).then(data => {
		  		 		 if(data.code==200){
		  		 			detailDesigner(this.$route.query.id).then(data => {
		  		 					 if(data.code==200){
		  		 						 this.detail=data.data
		  		 					 }
		  		 			})
		  		 		 }
		  		 })
		  }else if(this.$route.query.type==2){
		  		 updateHomeDecoration(this.detail).then(data => {
		  		 		 if(data.code==200){
		  		 			detailHomeDecoration(this.$route.query.id).then(data => {
		  		 					 if(data.code==200){
		  		 						 this.detail=data.data
		  		 					 }
		  		 			})
		  		 		 }
		  		 })
		  }
	  },
      cancel(){
		  this.$router.back();
	  }
    }}
</script>
